package android.marshon.likequanmintv.db;

import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.query.Query;
import org.greenrobot.greendao.query.QueryBuilder;

import android.marshon.likequanmintv.bean.PlayBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "PLAY_BEAN".
*/
public class PlayBeanDao extends AbstractDao<PlayBean, Long> {

    public static final String TABLENAME = "PLAY_BEAN";

    /**
     * Properties of entity PlayBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property Livecategory_id = new Property(1, Long.class, "livecategory_id", false, "LIVECATEGORY_ID");
        public final static Property Recommend_image = new Property(2, String.class, "recommend_image", false, "RECOMMEND_IMAGE");
        public final static Property Announcement = new Property(3, String.class, "announcement", false, "ANNOUNCEMENT");
        public final static Property Title = new Property(4, String.class, "title", false, "TITLE");
        public final static Property Create_at = new Property(5, String.class, "create_at", false, "CREATE_AT");
        public final static Property Intro = new Property(6, String.class, "intro", false, "INTRO");
        public final static Property Video = new Property(7, String.class, "video", false, "VIDEO");
        public final static Property Screen = new Property(8, int.class, "screen", false, "SCREEN");
        public final static Property Push_ip = new Property(9, String.class, "push_ip", false, "PUSH_IP");
        public final static Property Love_cover = new Property(10, String.class, "love_cover", false, "LOVE_COVER");
        public final static Property Category_id = new Property(11, String.class, "category_id", false, "CATEGORY_ID");
        public final static Property Video_quality = new Property(12, String.class, "video_quality", false, "VIDEO_QUALITY");
        public final static Property Like = new Property(13, String.class, "like", false, "LIKE");
        public final static Property Default_image = new Property(14, String.class, "default_image", false, "DEFAULT_IMAGE");
        public final static Property Slug = new Property(15, String.class, "slug", false, "SLUG");
        public final static Property Weight = new Property(16, String.class, "weight", false, "WEIGHT");
        public final static Property Status = new Property(17, String.class, "status", false, "STATUS");
        public final static Property Level = new Property(18, String.class, "level", false, "LEVEL");
        public final static Property Avatar = new Property(19, String.class, "avatar", false, "AVATAR");
        public final static Property Uid = new Property(20, String.class, "uid", false, "UID");
        public final static Property Play_at = new Property(21, String.class, "play_at", false, "PLAY_AT");
        public final static Property View = new Property(22, String.class, "view", false, "VIEW");
        public final static Property Category_slug = new Property(23, String.class, "category_slug", false, "CATEGORY_SLUG");
        public final static Property Nick = new Property(24, String.class, "nick", false, "NICK");
        public final static Property Beauty_cover = new Property(25, String.class, "beauty_cover", false, "BEAUTY_COVER");
        public final static Property App_shuffling_image = new Property(26, String.class, "app_shuffling_image", false, "APP_SHUFFLING_IMAGE");
        public final static Property Start_time = new Property(27, String.class, "start_time", false, "START_TIME");
        public final static Property Follow = new Property(28, int.class, "follow", false, "FOLLOW");
        public final static Property Category_name = new Property(29, String.class, "category_name", false, "CATEGORY_NAME");
        public final static Property Thumb = new Property(30, String.class, "thumb", false, "THUMB");
        public final static Property Grade = new Property(31, String.class, "grade", false, "GRADE");
        public final static Property Hidden = new Property(32, boolean.class, "hidden", false, "HIDDEN");
        public final static Property Icontext = new Property(33, String.class, "icontext", false, "ICONTEXT");
    }

    private Query<PlayBean> liveCategory_ListQuery;

    public PlayBeanDao(DaoConfig config) {
        super(config);
    }
    
    public PlayBeanDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"PLAY_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
                "\"LIVECATEGORY_ID\" INTEGER," + // 1: livecategory_id
                "\"RECOMMEND_IMAGE\" TEXT," + // 2: recommend_image
                "\"ANNOUNCEMENT\" TEXT," + // 3: announcement
                "\"TITLE\" TEXT," + // 4: title
                "\"CREATE_AT\" TEXT," + // 5: create_at
                "\"INTRO\" TEXT," + // 6: intro
                "\"VIDEO\" TEXT," + // 7: video
                "\"SCREEN\" INTEGER NOT NULL ," + // 8: screen
                "\"PUSH_IP\" TEXT," + // 9: push_ip
                "\"LOVE_COVER\" TEXT," + // 10: love_cover
                "\"CATEGORY_ID\" TEXT," + // 11: category_id
                "\"VIDEO_QUALITY\" TEXT," + // 12: video_quality
                "\"LIKE\" TEXT," + // 13: like
                "\"DEFAULT_IMAGE\" TEXT," + // 14: default_image
                "\"SLUG\" TEXT," + // 15: slug
                "\"WEIGHT\" TEXT," + // 16: weight
                "\"STATUS\" TEXT," + // 17: status
                "\"LEVEL\" TEXT," + // 18: level
                "\"AVATAR\" TEXT," + // 19: avatar
                "\"UID\" TEXT," + // 20: uid
                "\"PLAY_AT\" TEXT," + // 21: play_at
                "\"VIEW\" TEXT," + // 22: view
                "\"CATEGORY_SLUG\" TEXT," + // 23: category_slug
                "\"NICK\" TEXT," + // 24: nick
                "\"BEAUTY_COVER\" TEXT," + // 25: beauty_cover
                "\"APP_SHUFFLING_IMAGE\" TEXT," + // 26: app_shuffling_image
                "\"START_TIME\" TEXT," + // 27: start_time
                "\"FOLLOW\" INTEGER NOT NULL ," + // 28: follow
                "\"CATEGORY_NAME\" TEXT," + // 29: category_name
                "\"THUMB\" TEXT," + // 30: thumb
                "\"GRADE\" TEXT," + // 31: grade
                "\"HIDDEN\" INTEGER NOT NULL ," + // 32: hidden
                "\"ICONTEXT\" TEXT);"); // 33: icontext
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"PLAY_BEAN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, PlayBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long livecategory_id = entity.getLivecategory_id();
        if (livecategory_id != null) {
            stmt.bindLong(2, livecategory_id);
        }
 
        String recommend_image = entity.getRecommend_image();
        if (recommend_image != null) {
            stmt.bindString(3, recommend_image);
        }
 
        String announcement = entity.getAnnouncement();
        if (announcement != null) {
            stmt.bindString(4, announcement);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(5, title);
        }
 
        String create_at = entity.getCreate_at();
        if (create_at != null) {
            stmt.bindString(6, create_at);
        }
 
        String intro = entity.getIntro();
        if (intro != null) {
            stmt.bindString(7, intro);
        }
 
        String video = entity.getVideo();
        if (video != null) {
            stmt.bindString(8, video);
        }
        stmt.bindLong(9, entity.getScreen());
 
        String push_ip = entity.getPush_ip();
        if (push_ip != null) {
            stmt.bindString(10, push_ip);
        }
 
        String love_cover = entity.getLove_cover();
        if (love_cover != null) {
            stmt.bindString(11, love_cover);
        }
 
        String category_id = entity.getCategory_id();
        if (category_id != null) {
            stmt.bindString(12, category_id);
        }
 
        String video_quality = entity.getVideo_quality();
        if (video_quality != null) {
            stmt.bindString(13, video_quality);
        }
 
        String like = entity.getLike();
        if (like != null) {
            stmt.bindString(14, like);
        }
 
        String default_image = entity.getDefault_image();
        if (default_image != null) {
            stmt.bindString(15, default_image);
        }
 
        String slug = entity.getSlug();
        if (slug != null) {
            stmt.bindString(16, slug);
        }
 
        String weight = entity.getWeight();
        if (weight != null) {
            stmt.bindString(17, weight);
        }
 
        String status = entity.getStatus();
        if (status != null) {
            stmt.bindString(18, status);
        }
 
        String level = entity.getLevel();
        if (level != null) {
            stmt.bindString(19, level);
        }
 
        String avatar = entity.getAvatar();
        if (avatar != null) {
            stmt.bindString(20, avatar);
        }
 
        String uid = entity.getUid();
        if (uid != null) {
            stmt.bindString(21, uid);
        }
 
        String play_at = entity.getPlay_at();
        if (play_at != null) {
            stmt.bindString(22, play_at);
        }
 
        String view = entity.getView();
        if (view != null) {
            stmt.bindString(23, view);
        }
 
        String category_slug = entity.getCategory_slug();
        if (category_slug != null) {
            stmt.bindString(24, category_slug);
        }
 
        String nick = entity.getNick();
        if (nick != null) {
            stmt.bindString(25, nick);
        }
 
        String beauty_cover = entity.getBeauty_cover();
        if (beauty_cover != null) {
            stmt.bindString(26, beauty_cover);
        }
 
        String app_shuffling_image = entity.getApp_shuffling_image();
        if (app_shuffling_image != null) {
            stmt.bindString(27, app_shuffling_image);
        }
 
        String start_time = entity.getStart_time();
        if (start_time != null) {
            stmt.bindString(28, start_time);
        }
        stmt.bindLong(29, entity.getFollow());
 
        String category_name = entity.getCategory_name();
        if (category_name != null) {
            stmt.bindString(30, category_name);
        }
 
        String thumb = entity.getThumb();
        if (thumb != null) {
            stmt.bindString(31, thumb);
        }
 
        String grade = entity.getGrade();
        if (grade != null) {
            stmt.bindString(32, grade);
        }
        stmt.bindLong(33, entity.getHidden() ? 1L: 0L);
 
        String icontext = entity.getIcontext();
        if (icontext != null) {
            stmt.bindString(34, icontext);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, PlayBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long livecategory_id = entity.getLivecategory_id();
        if (livecategory_id != null) {
            stmt.bindLong(2, livecategory_id);
        }
 
        String recommend_image = entity.getRecommend_image();
        if (recommend_image != null) {
            stmt.bindString(3, recommend_image);
        }
 
        String announcement = entity.getAnnouncement();
        if (announcement != null) {
            stmt.bindString(4, announcement);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(5, title);
        }
 
        String create_at = entity.getCreate_at();
        if (create_at != null) {
            stmt.bindString(6, create_at);
        }
 
        String intro = entity.getIntro();
        if (intro != null) {
            stmt.bindString(7, intro);
        }
 
        String video = entity.getVideo();
        if (video != null) {
            stmt.bindString(8, video);
        }
        stmt.bindLong(9, entity.getScreen());
 
        String push_ip = entity.getPush_ip();
        if (push_ip != null) {
            stmt.bindString(10, push_ip);
        }
 
        String love_cover = entity.getLove_cover();
        if (love_cover != null) {
            stmt.bindString(11, love_cover);
        }
 
        String category_id = entity.getCategory_id();
        if (category_id != null) {
            stmt.bindString(12, category_id);
        }
 
        String video_quality = entity.getVideo_quality();
        if (video_quality != null) {
            stmt.bindString(13, video_quality);
        }
 
        String like = entity.getLike();
        if (like != null) {
            stmt.bindString(14, like);
        }
 
        String default_image = entity.getDefault_image();
        if (default_image != null) {
            stmt.bindString(15, default_image);
        }
 
        String slug = entity.getSlug();
        if (slug != null) {
            stmt.bindString(16, slug);
        }
 
        String weight = entity.getWeight();
        if (weight != null) {
            stmt.bindString(17, weight);
        }
 
        String status = entity.getStatus();
        if (status != null) {
            stmt.bindString(18, status);
        }
 
        String level = entity.getLevel();
        if (level != null) {
            stmt.bindString(19, level);
        }
 
        String avatar = entity.getAvatar();
        if (avatar != null) {
            stmt.bindString(20, avatar);
        }
 
        String uid = entity.getUid();
        if (uid != null) {
            stmt.bindString(21, uid);
        }
 
        String play_at = entity.getPlay_at();
        if (play_at != null) {
            stmt.bindString(22, play_at);
        }
 
        String view = entity.getView();
        if (view != null) {
            stmt.bindString(23, view);
        }
 
        String category_slug = entity.getCategory_slug();
        if (category_slug != null) {
            stmt.bindString(24, category_slug);
        }
 
        String nick = entity.getNick();
        if (nick != null) {
            stmt.bindString(25, nick);
        }
 
        String beauty_cover = entity.getBeauty_cover();
        if (beauty_cover != null) {
            stmt.bindString(26, beauty_cover);
        }
 
        String app_shuffling_image = entity.getApp_shuffling_image();
        if (app_shuffling_image != null) {
            stmt.bindString(27, app_shuffling_image);
        }
 
        String start_time = entity.getStart_time();
        if (start_time != null) {
            stmt.bindString(28, start_time);
        }
        stmt.bindLong(29, entity.getFollow());
 
        String category_name = entity.getCategory_name();
        if (category_name != null) {
            stmt.bindString(30, category_name);
        }
 
        String thumb = entity.getThumb();
        if (thumb != null) {
            stmt.bindString(31, thumb);
        }
 
        String grade = entity.getGrade();
        if (grade != null) {
            stmt.bindString(32, grade);
        }
        stmt.bindLong(33, entity.getHidden() ? 1L: 0L);
 
        String icontext = entity.getIcontext();
        if (icontext != null) {
            stmt.bindString(34, icontext);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public PlayBean readEntity(Cursor cursor, int offset) {
        PlayBean entity = new PlayBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // livecategory_id
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // recommend_image
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // announcement
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // title
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // create_at
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // intro
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // video
            cursor.getInt(offset + 8), // screen
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // push_ip
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // love_cover
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // category_id
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // video_quality
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // like
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // default_image
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // slug
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // weight
            cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // status
            cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // level
            cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // avatar
            cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // uid
            cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // play_at
            cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // view
            cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // category_slug
            cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // nick
            cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // beauty_cover
            cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26), // app_shuffling_image
            cursor.isNull(offset + 27) ? null : cursor.getString(offset + 27), // start_time
            cursor.getInt(offset + 28), // follow
            cursor.isNull(offset + 29) ? null : cursor.getString(offset + 29), // category_name
            cursor.isNull(offset + 30) ? null : cursor.getString(offset + 30), // thumb
            cursor.isNull(offset + 31) ? null : cursor.getString(offset + 31), // grade
            cursor.getShort(offset + 32) != 0, // hidden
            cursor.isNull(offset + 33) ? null : cursor.getString(offset + 33) // icontext
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, PlayBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setLivecategory_id(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setRecommend_image(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setAnnouncement(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setTitle(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setCreate_at(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setIntro(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setVideo(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setScreen(cursor.getInt(offset + 8));
        entity.setPush_ip(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setLove_cover(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setCategory_id(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setVideo_quality(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setLike(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setDefault_image(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setSlug(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setWeight(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setStatus(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
        entity.setLevel(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
        entity.setAvatar(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
        entity.setUid(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
        entity.setPlay_at(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21));
        entity.setView(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22));
        entity.setCategory_slug(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23));
        entity.setNick(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24));
        entity.setBeauty_cover(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25));
        entity.setApp_shuffling_image(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26));
        entity.setStart_time(cursor.isNull(offset + 27) ? null : cursor.getString(offset + 27));
        entity.setFollow(cursor.getInt(offset + 28));
        entity.setCategory_name(cursor.isNull(offset + 29) ? null : cursor.getString(offset + 29));
        entity.setThumb(cursor.isNull(offset + 30) ? null : cursor.getString(offset + 30));
        entity.setGrade(cursor.isNull(offset + 31) ? null : cursor.getString(offset + 31));
        entity.setHidden(cursor.getShort(offset + 32) != 0);
        entity.setIcontext(cursor.isNull(offset + 33) ? null : cursor.getString(offset + 33));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(PlayBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(PlayBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(PlayBean entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
    /** Internal query to resolve the "list" to-many relationship of LiveCategory. */
    public List<PlayBean> _queryLiveCategory_List(Long livecategory_id) {
        synchronized (this) {
            if (liveCategory_ListQuery == null) {
                QueryBuilder<PlayBean> queryBuilder = queryBuilder();
                queryBuilder.where(Properties.Livecategory_id.eq(null));
                liveCategory_ListQuery = queryBuilder.build();
            }
        }
        Query<PlayBean> query = liveCategory_ListQuery.forCurrentThread();
        query.setParameter(0, livecategory_id);
        return query.list();
    }

}
